package org.example.字符串匹配字串出现的索引位置;

public class BF算法 {
	public static void main(String[] args) {
		System.out.println(bf("qwert", "ery"));
	}

	public static int bf(String a, String b) {
		for (int i = 0; i <= a.length() - b.length(); i++) {
			int k = 0;
			for (; k < b.length(); k++) {
				if (a.charAt(i + k) != b.charAt(k)) {
					break;
				}
			}
			if (k == b.length()) {
				return i;
			}
		}
		return -1;
	}
}
